<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="./../../resources/estoque.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:="http://www.w3.org/1999/xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="estilo.css" />
        <h:outputScript library="js" name="javaScript.js" />
        <p:separator />
        <div class="pagina">
            Cadastro de Fornecedor
        </div>        
        <p:separator />
        <h:form id="frmDados">
            <p:growl />
            <h:inputHidden value="#{mbFornecedor.fornecedor.idFornecedor}" />
            <h:panelGrid columns="4">
                <h:outputLabel value="Nome Fantasia.:" for="nomefantasia" styleClass="lb" />
                <h:inputText id="nomefantasia" value="#{mbFornecedor.fornecedor.nomeFantasia}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="60" />
                <h:outputLabel value="Razão Social.:" for="razaosocial" styleClass="lb" />
                <h:inputText id="razaosocial" value="#{mbFornecedor.fornecedor.razaoSocial}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="50" />
            </h:panelGrid>
            <h:panelGrid columns="4">
                <h:outputLabel value="CNPJ/CPF.:" for="cnpjcpf" styleClass="lb" />
                <h:inputText id="cnpjcpf" value="#{mbFornecedor.fornecedor.cnpjCpf}" styleClass="tx" size="25" />
                <h:outputLabel value="Insc. Estadula.:" for="inscestadual" styleClass="lb" />
                <h:inputText id="inscestadual" value="#{mbFornecedor.fornecedor.inscricaoEstadual}" styleClass="tx" size="25" />
            </h:panelGrid>
            <h:panelGrid columns="6">
                <h:outputLabel value="Endereço.:" for="endereco" styleClass="lb"/>
                <h:inputText id="endereco" value="#{mbFornecedor.fornecedor.endereco}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="45" />
                <h:outputLabel value="Bairro.:" for="bairro" styleClass="lb" />
                <h:inputText id="bairro" value="#{mbFornecedor.fornecedor.bairro}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="35" />
                <h:outputLabel value="Município.:" for="municipio" styleClass="lb" />
                <h:selectOneMenu id="municipio" value="#{mbFornecedor.fornecedor.cidade.idCidade}" styleClass="tx" style="width: 200px;" required="true" requiredMessage="Campo município e obrigatório">
                    <f:selectItem itemValue="" itemLabel="-" /> 
                    <f:selectItems value="#{mbCidade.cidades}" var="c" itemValue="#{c.idCidade}" itemLabel="#{c.cidade} - #{c.uf}" />                    
                </h:selectOneMenu>
            </h:panelGrid>
            <h:panelGrid columns="4">
                <h:outputLabel value="CEP.:" for="cep" styleClass="lb" />
                <h:inputText id="cep" value="#{mbFornecedor.fornecedor.cep}" styleClass="tx" size="25" />
                <h:outputLabel value="Contato.:" for="contato" styleClass="lb" />
                <h:inputText id="contato" value="#{mbFornecedor.fornecedor.nomeContato}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="50" />
            </h:panelGrid>
            <h:panelGrid columns="6">
                <h:outputLabel value="Telefone.:" for="fone1" styleClass="lb" />
                <h:inputText id="fone1" value="#{mbFornecedor.fornecedor.fone1}" styleClass="tx" size="25" />
                <h:outputLabel value="Celular.:" for="fone2" styleClass="lb" />
                <h:inputText id="fone2" value="#{mbFornecedor.fornecedor.fone2}" styleClass="tx" size="25" />
                <h:outputLabel value="Fax.:" for="fax" styleClass="lb" />
                <h:inputText id="fax" value="#{mbFornecedor.fornecedor.fax}" styleClass="tx" size="25" />
            </h:panelGrid>
            <h:panelGrid columns="4">
                <h:outputLabel value="Email.:" for="email" styleClass="lb" />
                <h:inputText id="email" value="#{mbFornecedor.fornecedor.email}" styleClass="tx" onkeyup="this.value = this.value.toLowerCase()" size="50" />
                <h:outputLabel value="Ramo de Atualção.:" for="ramo" styleClass="lb" />
                <h:inputText id="ramo" value="#{mbFornecedor.fornecedor.ramoDeAtuacao}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="50" />
            </h:panelGrid>
            <h:panelGrid columns="4">
                <h:outputLabel value="Obs.:" for="obs" styleClass="lb" />
                <h:inputText id="obs" value="#{mbFornecedor.fornecedor.obs}" styleClass="tx" onkeyup="this.value = this.value.toUpperCase()" size="50" />
                <p:commandButton value="Cancelar" action="#{mbFornecedor.cancelaAlteracao}"  update=":frmDados" ajax="false" immediate="true" />                  
                <p:commandButton value="Salvar" action="#{mbFornecedor.salvaFornecedor}" update="@form :frmTable" ajax="false" />
            </h:panelGrid>
        </h:form>
        <p:separator />
        <h:form id="frmPesqHospede">
            <fieldset>
                <legend style="font-size: 18px; color: #D20005">Pesquisar Fornecedor</legend>
                <h:panelGrid columns="3">                   
                    <h:outputLabel value="Fornecedor.:" styleClass="lb" style="float: left;"/>
                    <h:inputText value="#{mbFornecedor.pesquisaFornecedor}" onkeyup="this.value = this.value.toUpperCase()" 
                                 styleClass="tx" style="color: #D20005;" size="40">                
                    </h:inputText>                   
                    <p:commandLink action="#{mbFornecedor.pesquisarFornecedor}" update=":frmTable" title="Click para realizar a pesquisa" ajax="false">
                        <h:graphicImage library="img" name="lupa2.bmp" />
                    </p:commandLink>
                </h:panelGrid>
            </fieldset>
        </h:form>
        <p:separator />
        <h:form id="frmTable">
            <p:dataTable value="#{mbFornecedor.fornecedores}" var="f" rendered="#{mbFornecedor.fornecedores.size() > 0}">
                <p:column headerText="Cod" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.idFornecedor}" styleClass="txt" />
                </p:column>
                <p:column headerText="Nome Fantasia" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.nomeFantasia}" styleClass="txt" />
                </p:column>
                <p:column headerText="CNPJ/CPF" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.cnpjCpf}" styleClass="txt" />
                </p:column>
                <p:column headerText="Insc. Estadual" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.inscricaoEstadual}" styleClass="txt" />
                </p:column>
                <p:column headerText="Fone" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.fone1}" styleClass="txt" />
                </p:column>
                <p:column headerText="Contato" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.nomeContato}" styleClass="txt" />
                </p:column>
                <p:column headerText="E-mail" style="text-align: left; font-size: 12px;">
                    <h:outputText value="#{f.email}" styleClass="txt" />
                </p:column>
                <p:column headerText="Alterar" style="text-align: center; font-size: 12px;" width="50">
                    <p:commandLink action="#{mbFornecedor.alterarFornecedor(f)}" ajax="false" update=":frmDados">
                        <h:graphicImage name="edicao.png" library="img" />
                    </p:commandLink>
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>

</ui:composition>
